package q1.project.modules.system.role.entity;

import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import q1.project.common.enums.EnableStatusEnum;
import q1.project.core.entity.BaseEntity;
import q1.project.core.jpa.annotation.Comment;

/**
 * 权限实体
 *
 * @author Q1 Team
 * @version 1.0
 */
@Getter
@Setter
@Entity
@Table(
    name = "q1_permission",
    indexes = {
      @Index(name = "idx_permission_code", columnList = "permission_code"),
      @Index(name = "idx_module", columnList = "module")
    })
public class PermissionEntity extends BaseEntity {

  /** 权限编码(唯一) */
  @Comment("权限编码")
  @Column(name = "permission_code", nullable = false, length = 100)
  private String permissionCode;

  /** 权限名称 */
  @Comment("权限名称")
  @Column(name = "permission_name", nullable = false, length = 100)
  private String permissionName;

  /** 权限描述 */
  @Comment("权限描述")
  @Column(length = 200)
  private String description;

  /** 所属模块 */
  @Comment("所属模块")
  @Column(length = 50)
  private String module;

  /** 资源 */
  @Comment("资源")
  @Column(length = 100)
  private String resource;

  /** 操作 */
  @Comment("操作")
  @Column(length = 50)
  private String action;

  /** 状态：ACTIVE-激活 DISABLED-禁用 */
  @Comment("状态")
  @Enumerated(EnumType.STRING)
  @Column(nullable = false, length = 20)
  private EnableStatusEnum status = EnableStatusEnum.ACTIVE;
}
